<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>猜数字</title>
</head>
<body>
    <script>
        var min,max;
        min=1;
        max=10;
        var x=parseInt((Math.random())*10+1);
        
        while(true){
            var y=Number(prompt("请输入您猜测的数字"+min+"~"+max));
            if(y>max||y<min)
            {
                alert('请重新输入');
                continue;
            }
            if(y>x){
                alert('你猜大了');
                max=y;
            }
            else if(x>y){
                alert('你猜小了');
                min=y;
            }
            else
            {
                alert("大聪明")
                break;
            }

        }
    </script>
</body>
</html>